# Maintainer: Alexey Pavlov <alexpux@gmail.com>

pkgname=grep
pkgver=2.22
pkgrel=1
pkgdesc="A string search utility"
arch=('i686' 'x86_64')
license=('GPL3')
url="http://www.gnu.org/software/grep/grep.html"
groups=('base' 'base-devel')
depends=('libiconv' 'libintl' 'libpcre' 'sh')
makedepends=('texinfo' 'gettext-devel' 'libiconv-devel' 'pcre-devel')
install=${pkgname}.install
source=(ftp://ftp.gnu.org/gnu/$pkgname/$pkgname-$pkgver.tar.xz{,.sig}
        grep-2.16-msys2.patch)
md5sums=('e1015e951a49a82b02e38891026ef5df'
         'SKIP'
         '783c1e4d7185d8c78fde776270c6be43')

prepare() {
  cd ${srcdir}/${pkgname}-${pkgver}

  patch -p1 -i ${srcdir}/grep-2.16-msys2.patch

  autoreconf -fi
}

build() {
  cd ${srcdir}/${pkgname}-${pkgver}
  ./configure --build=${CHOST} \
      --prefix=/usr \
      --without-libiconv-prefix \
      --without-libintl-prefix
  make
}

check() {
  cd ${srcdir}/${pkgname}-${pkgver}
  make check
}

package() {
  cd ${srcdir}/${pkgname}-${pkgver}
  make DESTDIR=${pkgdir} install
}
